package com.csii.ssm.model;

import com.csii.ssm.model.type.RuleType;

import javax.persistence.*;

public class Rule {
    /**
     * 规则id
     */
    @Column(name = "rule_id")
    private String ruleId;

    /**
     * 规则类型
     */
    @Column(name = "rule_type")
    private String ruleType;

    /**
     * 用户类型,CLIENT,SUPERADMIN,MEROPERATOR
     */
    @Column(name = "user_type")
    private String userType;

    /**
     * 规则定义
     */
    @Column(name = "rule_def")
    private String ruleDef;

    /**
     * 规则说明
     */
    @Column(name = "rule_memo")
    private String ruleMemo;

    /**
     * 获取规则id
     *
     * @return rule_id - 规则id
     */
    public String getRuleId() {
        return ruleId;
    }

    /**
     * 设置规则id
     *
     * @param ruleId 规则id
     */
    public void setRuleId(String ruleId) {
        this.ruleId = ruleId;
    }

    /**
     * 获取规则类型
     *
     * @return rule_type - 规则类型
     */
    public String getRuleType() {
        return ruleType;
    }

    /**
     * 设置规则类型
     *
     * @param ruleType 规则类型
     */
    public void setRuleType(String ruleType) {
        this.ruleType = ruleType;
    }

    /**
     * 获取用户类型,CLIENT,SUPERADMIN,MEROPERATOR
     *
     * @return user_type - 用户类型,CLIENT,SUPERADMIN,MEROPERATOR
     */
    public String getUserType() {
        return userType;
    }

    /**
     * 设置用户类型,CLIENT,SUPERADMIN,MEROPERATOR
     *
     * @param userType 用户类型,CLIENT,SUPERADMIN,MEROPERATOR
     */
    public void setUserType(String userType) {
        this.userType = userType;
    }

    /**
     * 获取规则定义
     *
     * @return rule_def - 规则定义
     */
    public String getRuleDef() {
        return ruleDef;
    }

    /**
     * 设置规则定义
     *
     * @param ruleDef 规则定义
     */
    public void setRuleDef(String ruleDef) {
        this.ruleDef = ruleDef;
    }

    /**
     * 获取规则说明
     *
     * @return rule_memo - 规则说明
     */
    public String getRuleMemo() {
        return ruleMemo;
    }

    /**
     * 设置规则说明
     *
     * @param ruleMemo 规则说明
     */
    public void setRuleMemo(String ruleMemo) {
        this.ruleMemo = ruleMemo;
    }

    public static Rule newInstance(String ruleId, String ruleType, RuleType.Type type) {
        Rule rule = new Rule();
        rule.setRuleId(ruleId);
        rule.setRuleType(ruleType);
        rule.setUserType(String.valueOf(type));
        return rule;
    }

    @Override
    public String toString() {
        return "Rule{" +
                "ruleId='" + ruleId + '\'' +
                ", ruleType='" + ruleType + '\'' +
                ", userType='" + userType + '\'' +
                ", ruleDef='" + ruleDef + '\'' +
                ", ruleMemo='" + ruleMemo + '\'' +
                '}';
    }
}